package com.zhss.eshop.membership.mapper;

import com.zhss.eshop.membership.domain.model.MembershipMemberLevel;
import org.apache.ibatis.annotations.*;

@Mapper
public interface MembershipMemberLevelMapper {
    int deleteByPrimaryKey(Long id);

    int insertSelective(MembershipMemberLevel record);

    MembershipMemberLevel selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(MembershipMemberLevel record);

    /**
     * 根据用户账号id查询会员等级`
     * @param userAccountId 用户账号id
     * @return 会员等级
     */
    @Select("SELECT "
            + "id,"
            + "user_account_id,"
            + "growth_value,"
            + "level,"
            + "gmt_create,"
            + "gmt_modified "
            + "FROM membership_member_level "
            + "WHERE user_account_id=#{userAccountId}")
    @Results({
            @Result(column = "id", property = "id", id = true),
            @Result(column = "user_account_id", property = "userAccountId"),
            @Result(column = "growth_value", property = "growthValue"),
            @Result(column = "level", property = "level"),
            @Result(column = "gmt_create", property = "gmtCreate"),
            @Result(column = "gmt_modified", property = "gmtModified")
    })
    MembershipMemberLevel getByUserAccountId(@Param("userAccountId") Long userAccountId);
}
